package partTwo;
public class Outter {
    String outString = "publicstring";
    private String outPrivateString = "privatestring";

    static String outStaticString = "staticOuterstring";

    public String getOutPrivateString() {
        return outPrivateString;
    }

    public void setOutPrivateString(String outPrivateString) {
        this.outPrivateString = outPrivateString;
    }

    public void outFind(){
        System.out.println("out...find");
        System.out.println("外部类不能直接使用内部类成员，需要创建内部类对象后调用");

        Inner inner = new Inner();
        System.out.println("在外部类中创建内部类对象，调用内部类资源"+inner.innerString);
        System.out.println("在外部类中创建内部类对象，调用内部类资源"+inner.innerPrivateString);
        System.out.println("在外部类中创建内部类对象，调用内部类资源");
        inner.innerFind();
        inner.innerPrivateFind();

        InnerStatic innerStatic = new InnerStatic();
        System.out.println("在外部类中创建内部类对象，调用内部类资源"+innerStatic.innerString);
        System.out.println("在外部类中创建内部类对象，调用内部类资源"+innerStatic.innerPrivateString);
        System.out.println("在外部类中创建内部类对象，调用内部类资源"+innerStatic.innerStaticString); //静态成员变量可以调用，但是IDEA不会提示输入，其认为这不是调用的最好方式
        innerStatic.innerFind();
        innerStatic.innerPrivateFind();
        innerStatic.innerStaticFind();//静态成员方法可以调用，但是IDEA不会提示输入，其认为这不是调用的最好方式

        InnerPrivate innerPrivate = new InnerPrivate();
        System.out.println("在外部类中创建内部类对象，调用内部类资源"+innerPrivate.innerString);
        System.out.println("在外部类中创建内部类对象，调用内部类资源"+innerPrivate.innerPrivateString);
        System.out.println("在外部类中创建内部类对象，调用内部类资源");
        innerPrivate.innerFind();
        innerPrivate.innerPrivateFind();


    }

    public static void outStaticFind(){
        System.out.println("out----static...find");
    }

    private void outPrivateFind(){
        System.out.println("out...private...find");
    }

    public void getInnerPrivateMethod(){
        Inner inner = new Inner();
        System.out.println("在外部类中创建方法调用内部类私有资源"+inner.innerPrivateString);
        inner.innerPrivateFind();
    }
    //普通成员内部类
    class Inner{
        String innerString = "innerstring";
        //static String innerStaticString = "innerstaticstring"; //非静态类不允许创建静态变量
        private String innerPrivateString = "innerprivateinner";

        public String getInnerPrivateString() {
            return innerPrivateString;
        }

        public void setInnerPrivateString(String innerPrivateString) {
            this.innerPrivateString = innerPrivateString;
        }

        public void innerFind(){
            System.out.println("inner....find");
            System.out.println("普通成员内部类可以直接调用外部类的成员变量"+outString);
            System.out.println("普通成员内部类可以直接调用外部类的私有成员变量"+outPrivateString);
            System.out.println("普通成员内部类可以直接调用外部类的静态成员变量"+outStaticString);
        }
        //static public void innerStaticFind(){System.out.println("inner...static...find");} //非静态类不允许创建静态方法

        private void innerPrivateFind(){
            System.out.println("inner...private...find");
            System.out.println("普通成员内部类可以直接调用外部类的成员方法");
            outFind();
            System.out.println("普通成员内部类可以直接调用外部类的静态方法");
            outStaticFind();
            System.out.println("普通成员内部类可以直接调用外部类的私有方法");
            outPrivateFind();
        }
    }

    //静态成员内部类
    static class InnerStatic{
        String innerString = "innerstring";
        static String innerStaticString = "innerstaticstring";
        private String innerPrivateString = "innerprivatestring";

        public String getInnerPrivateString() {
            return innerPrivateString;
        }

        public void setInnerPrivateString(String innerPrivateString) {
            this.innerPrivateString = innerPrivateString;
        }

        public void innerFind(){
            System.out.println("inner...find");
            //System.out.println("可以直接调用外部类的成员变量"+outString);   //静态内部类不能调用外部类的成员变量
            //System.out.println("可以直接调用外部类的私有成员变量"+outPrivateString);  //静态内部类不能调用外部类的私有变量
            System.out.println("静态内部类只能调用外部类的静态成员变量"+outStaticString);
        }
        static public void innerStaticFind(){
            System.out.println("inner...static...find");
            System.out.println("静态内部类不能调用外部类的成员方法");
            //outFind();
            System.out.println("静态内部类可以直接调用外部类的静态方法");
            outStaticFind();
            System.out.println("静态内部类不能调用外部类的私有方法");
            //outPrivateFind();
        }

        private void innerPrivateFind(){
            System.out.println("inner...private...find");
        }

    }

    //私有成员内部类
    private class InnerPrivate{
        String innerString = "innerstring";
        //static String innerStaticString = "innerstaticstring"; //非静态类不允许创建静态变量
        private String innerPrivateString = "innerprivatestring";

        public String getInnerPrivateString() {
            return innerPrivateString;
        }

        public void setInnerPrivateString(String innerPrivateString) {
            this.innerPrivateString = innerPrivateString;
        }

        public void innerFind(){
            System.out.println("inner....find");
            System.out.println("私有成员内部类可以直接调用外部类的成员变量"+outString);
            System.out.println("私有成员内部类可以直接调用外部类的私有成员变量"+outPrivateString);
            System.out.println("私有成员内部类可以直接调用外部类的静态成员变量"+outStaticString);
        }
        //static public void innerStaticFind(){System.out.println("inner...static...find");} //非静态类不允许创建静态方法

        private void innerPrivateFind(){
            System.out.println("inner...private...find");
            System.out.println("私有成员内部类可以直接调用外部类的成员方法");
            outFind();
            System.out.println("私有成员内部类可以直接调用外部类的静态方法");
            outStaticFind();
            System.out.println("私有成员内部类可以直接调用外部类的私有方法");
            outPrivateFind();
        }
    }
}

